package com.cyj.qqserver.service;

import com.cyj.qqcommon.Message;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;

/**
 管理客户端通讯线程
 */
public class ManageServerConnectClientThread implements Serializable {
    private static HashMap<String,ServerConnectClientThread> hm=new HashMap<>();
    public static void addClient(String userId,ServerConnectClientThread serverConnectClientThread){
        hm.put(userId,serverConnectClientThread);
    }
    public static ServerConnectClientThread getServerConnectClientThread(String userId){
        return hm.get(userId);
    }
    public static String getOnlineUsers(){
        Iterator<String> iterator = hm.keySet().iterator();
        String onlineUserList="";
        while(iterator.hasNext()){
            String key = iterator.next();
            onlineUserList+=key.toString()+" ";
        }
        return onlineUserList;
    }
    public static void removeClient(String userId){
        hm.remove(userId);
    }

    public static HashMap<String, ServerConnectClientThread> getHm() {
        return hm;
    }
}
